package user

import (
	"chaowan/data_source"
	"chaowan/models"
	"github.com/gin-gonic/gin"
	"net/http"
)

type XieyiinfoBody struct {
	ID      int64  `json:"id" gorm:"id"`
	Name    string `json:"name" gorm:"name"`
	Content string `json:"content" gorm:"content"`
}

func Xieyiinfo(ctx *gin.Context) {
	request := XieyiinfoBody{}
	ctx.ShouldBind(&request)
	id := request.ID
	var users models.Xieyi
	data_source.Db.Where("id = ?", id).First(&users)

	ctx.JSON(http.StatusOK, gin.H{
		"code":    0,
		"error":   0,
		"success": 200,
		"data":    users,
		"msg":     "ok",
	})
	return

}
func Jieshaoinfo(ctx *gin.Context) {
	request := XieyiinfoBody{}
	ctx.ShouldBind(&request)
	id := request.ID
	var users models.Jieshao
	data_source.Db.Where("id = ?", id).First(&users)

	ctx.JSON(http.StatusOK, gin.H{
		"code":    0,
		"error":   0,
		"success": 200,
		"data":    users,
		"msg":     "ok",
	})
	return

}
func Paiminglist(ctx *gin.Context) {

	var users []models.Paiming
	data_source.Db.Order("paiming asc").Find(&users)

	ctx.JSON(http.StatusOK, gin.H{
		"code":    0,
		"error":   0,
		"success": 200,
		"data":    users,
		"msg":     "ok",
	})
	return

}
